package com.hnl.timer;

import java.util.Timer;
import java.util.TimerTask;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.hnl.util.HttpRequestSender;

public class SOLRTasksTimer extends TimerTask {
	static final Logger LOG = LoggerFactory.getLogger(SOLRTasksTimer.class);

	private String url;
	private String param;
	private String interval;

	public SOLRTasksTimer(String url, String param, String interval) {
		this.url = url;
		this.param = param;
		this.interval = interval;
	}

	public void init() {
		Timer timer = new Timer();
		timer.schedule(new SOLRTasksTimer(url, param, interval),
				Long.valueOf(interval));
	}

	public void run() {
		HttpRequestSender.sendGetRequest(url, param);
		Timer timer = new Timer();
		timer.schedule(new SOLRTasksTimer(url, param, interval),
				Long.valueOf(interval));
	}
}
